package hoowin.basic.model;

import java.io.Serializable;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

public class ModelBase implements Serializable {
	private static final long serialVersionUID = -3482635332255660470L;	
	private int id;

	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}
	
	public boolean equals(Object obj){
		if(this==obj) return true;
		if(obj==null || !(obj instanceof ModelBase))return false;
		ModelBase target = (ModelBase)obj;
		if(this.getId()!=0)return this.getId()==target.getId();
		return false;
	}
	
	public int hashCode(){
		if(this.getId()!=0)return new Integer(this.getId()).hashCode();
		return HashCodeBuilder.reflectionHashCode(this);
	}
	
	public String toString(){
		return ReflectionToStringBuilder.toString(this);
	}
}
